package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.apis.admin.AdSensitiveController;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author feihao
 * @version 1.0
 * @date 2021/7/22 10:09
 */

@RestController
@RequestMapping("/api/v1/sensitive")
public class SensitiveController implements AdSensitiveController {

    @Autowired
    private AdSensitiveService adSensitiveService;

    /**
     * 保存敏感词接口：
     * @param adSensitive
     * @return
     */
    @Override
    @PostMapping("save")
    public ResponseResult saveSensitive(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    /**
     * 按照name分页查询敏感词：
     * @param sensitiveDto
     * @return
     */
    @Override
    @PostMapping("list")
    public ResponseResult findByName(@RequestBody SensitiveDto sensitiveDto){
        return adSensitiveService.findByName(sensitiveDto);
    }

    /**
     * 修改敏感词
     * @param adSensitive
     * @return
     */
    @Override
    @PostMapping("update")
    public ResponseResult update(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.updateSensitive(adSensitive);
    }

    @Override
    @DeleteMapping("del/{id}")
    public ResponseResult deleteById(@PathVariable("id") Integer id){
        return adSensitiveService.deleteById(id);
    }
}
